<?php

	/**
	 * Defines an abstract class to be used for all Data Typing with PHP
	 * 
	 * @author Pablo Santiago Sánchez <phackwer@gmail.com>
	 * @copyright Copyright (c) 2008, Pablo Santiago Sánchez
	 * @license http://opensource.org/licenses/bsd-license.php BSD License
	 * @package pop
	 * @subpackage datatypes
	 */

	/**
	 * Class used to be the base for all others
	 * 
	 * @package pop
	 * @subpackage datatypes
	 */
	abstract class PTypeBase
	{
		protected 	$value;
		protected	$defaultval = null;
		protected	$size = null;

		/**
		 * Constructor, in which you must inform the default value.
		 * @param string $defaultval Default value.
		 */
		public function __construct($defaultval)
		{
			$this->__set("value", $defaultval);
			$this->defaultval 	= $defaultval;
		}

		/**
		 * Magic method used to get the value of the object
		 * @param string $name name of the value
		 * @return mixed 
		 */
		public function __get($name)
		{
			return $this->$name;
		}

		/**
		 * Magic method used to get the string of the value of the object
		 * @return string 
		 */
		public function __toString()
		{
			return (string)$this->value;
		}

		/**
		 * Resets current value for the default value 
		 */
		public function reset()
		{
			$this->value = $this->defaultval;
		}
	}
?>
